
import argparse
import sys
import contour

if __name__ == '__main__':
    print("开始运行...")
    parser = argparse.ArgumentParser(description="Process PNG to Shapefiles using TIF for georeferencing.")
    parser.add_argument('--png_folder', type=str, required=True, help="Path to the folder containing PNG files.")
    parser.add_argument('--tif_folder', type=str, required=True, help="Path to the folder containing TIF files for georeferencing.")
    parser.add_argument('--shapefile_folder', type=str, required=True, help="Path to the folder to save Shapefiles.")
    try:
        args = parser.parse_args()
        print("命令行参数解析成功...")
        print(args)  # 输出解析后的命令行参数
    except Exception as e:
        print(f"Argument parsing failed: {e}")
        sys.exit(1)

    # 调用函数处理所有 PNG 文件
    contour.process_png_to_shapefile(args.tif_folder, args.png_folder, args.shapefile_folder)

    # process_png_to_shapefile(
    #     "E:/Detection20250222/src/main/resources/datasets/1/test/tif/",
    #     "E:/Detection20250222/src/main/resources/predictResult/1/310/214/predictResult/",
    #     "E:/Detection20250222/src/main/resources/predictResult/1/310/214/predictResult/../shp/"
    # )